﻿@model RiderShop.Mobile.Modle.MyAccount.MyCommentModel

<div id="comment_@Model.ReviewType" class="commentlist">

    @if (Model.TotalCount == 0)
    {
        @Html.Raw("暂无评价");
    }
    else
    {
        if (Model.ProductCommentList != null && Model.ProductCommentList.Count > 0)
        {
            foreach (var item in Model.ProductCommentList)
            {
                <dl class="ReviewItem">
                    <dt>
                        <img src="~/Themes/RongJi/Style/base/imgs/default60.png" alt="@(string.IsNullOrEmpty(item.CustomerName)?"**":item.CustomerName.Substring(0,2)+"** -"+ item.RankName)" />
                        <div class="user_info">
                            <p>@(string.IsNullOrEmpty(item.CustomerName) ? "**" : item.CustomerName.Substring(0, 2) + "**    ")</p>
                            <p>@item.RankName</p>
                        </div>
                    </dt>
                    <dd>
                        <span class="lastUpdate">@item.InDateFormated</span>
                        <span class="stars @Html.Raw("star" + (int)item.Rating)"></span>
                        <h4>@item.Title</h4>
                        <table>
                            <tr>
                                <th>使用心得：</th>
                                <td>
                                    <p>
                                        @if (@item.MeritText != "")
                                        {
                                             @item.MeritText
                                        }
                                        else
                                        { 
                                            @Html.Raw("就是这么任性，一般人我不告诉TA~")
                                        }
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <th>不足：</th>
                                <td>
                                    <p>
                                        @if (@item.FaultsText != "")
                                        {
                                            @item.FaultsText
                                        }
                                        else
                                        {
                                            @Html.Raw("就是这么任性，一般人我不告诉TA~")
                                        }
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <th>优点及建议：</th>
                                <td>
                                    <p>
                                        @if (@item.ImproveText != "")
                                        {
                                            @item.ImproveText
                                        }
                                        else
                                        {
                                            @Html.Raw("就是这么任性，一般人我不告诉TA~")
                                        }
                                    </p>
                                </td>
                            </tr>
                        </table>
                    </dd>
                    <br class="clearfix">
                </dl>
            }

            <div class="clearfix pagin">
                @*<div class="pagin">
                        @if (Model.PageIndex > 0)
                        {
                            <a class="cp_@Model.ReviewType" pageindex="@(Model.PageIndex-1)">上一页</a>
                        }


                        @if (Model.TotalPage < 8)
                        {
                            for (int i = 0; i < Model.TotalPage; i++)
                            {
                                if (i == Model.PageIndex)
                                {
                                    <a href="javascript:void(0)" class="current">@(i + 1)</a>
                                }
                                else
                                {
                                    <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="@i">@(i + 1)</a>
                                }
                            }
                        }
                        else
                        {
                            if (Model.PageIndex < 4)
                            {
                                for (int i = 0; i < 5; i++)
                                {
                                    if (i == Model.PageIndex)
                                    {
                                        <a href="javascript:void(0)" class="current">@(i + 1)</a>
                                    }
                                    else
                                    {
                                        <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="@i">@(i + 1)</a>
                                    }
                                }
                                <span>...</span>
                                <a class="cp_@Model.ReviewType" pageindex="@(Model.TotalPage - 2)">@(Model.TotalPage - 1)</a>
                                <a class="cp_@Model.ReviewType" pageindex="@(Model.TotalPage - 1)">@(Model.TotalPage)</a>
                            }
                            else if (Model.PageIndex >= Model.TotalPage - 4)
                            {
                                <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="0">1</a>
                                <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="1">2</a>
                                <span>...</span>
                                for (int i = Model.TotalPage - 5; i < Model.TotalPage; i++)
                                {
                                    if (i == Model.PageIndex)
                                    {
                                        <a href="javascript:void(0)" class="current">@(i + 1)</a>
                                    }
                                    else
                                    {
                                        <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="@i">@(i + 1)</a>
                                    }
                                }
                            }
                            else
                            {
                                <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="0">1</a>

                                <span>...</span>
                                for (int i = Model.PageIndex - 2; i < Model.PageIndex + 3; i++)
                                {
                                    if (i == Model.PageIndex)
                                    {
                                        <a href="javascript:void(0)" class="current">@(i + 1)</a>
                                    }
                                    else
                                    {
                                        <a href="#Tabs3" class="cp_@Model.ReviewType" pageindex="@i">@(i + 1)</a>
                                    }
                                }
                                <span>...</span>

                                <a class="cp_@Model.ReviewType" pageindex="@(Model.TotalPage - 1)">@(Model.TotalPage)</a>
                            }

                        }


                        @if (Model.PageIndex + 1 < Model.TotalPage)
                        {
                            <a class="cp_@Model.ReviewType" pageindex="@(Model.PageIndex+1)">下一页</a>
                        }
                        <script>
                            $(".cp_@Model.ReviewType").click(function () {

                                var pageIndex = $(this).attr("pageindex");
                                var type = @Model.ReviewType;
                                KevinShop.Common.Ajax.Get("CommentList?productId=" + @Model.ProductCommentList[0].ProductId +"&pageIndex=" + pageIndex + "&type=" + type,
                                    function (html) {
                                        $("#comment_@Model.ReviewType").parent().html(html);
                                    }
                                );

                            });
                        </script>
                    </div>*@

                @Html.Partial(string.Format("~/Themes/{0}/Views/Shared/Pagination.cshtml", Kevin.Shop.Business.Service.Entity.Helper.WebClientContext.Current.SiteTheme), Model)
                <script>
                $(".listPager .item").click(function () {

                    var pageIndex = $(this).attr("pageindex");
                    if (pageIndex) {
                        var type = @Model.ReviewType;
                        KevinShop.Common.Ajax.Get("CommentList?productId=" + @Model.ProductCommentList[0].ProductId +"&pageIndex=" + pageIndex + "&type=" + type,
                            function (html) {
                                if(html)
                                {
                                    $("#comment_@Model.ReviewType").parent().html(html);
                                }
                            }
                        );
                        window.location.href = "#Tab3";
                    }
                });
                </script>

            </div>
            <br class="clearfix">
        }
    }
</div>
